package servlet;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import ktoaon.pojo.KtDept;
import ktoaon.service.KtDeptService;
import ktoaon.service.KtEmpService;
import ktoaon.service.impl.KtDeptServiceimpl;
import ktoaon.service.impl.KtEmpServiceimpl;

import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class seleKtDept extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("测试1");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("测试2");
        KtDeptService ktDeptService=new KtDeptServiceimpl();
        KtEmpService ktEmpService=new KtEmpServiceimpl();
        JSONArray json = new JSONArray();
        KtDept[] list = ktDeptService.sele().toArray(new KtDept[0]);
        for(KtDept pLog : list){
            JSONObject jo = new JSONObject();
            jo.put("pid", pLog.getPid());
            jo.put("deptno", pLog.getDeptno());
            jo.put("dname", pLog.getDname());
            json.add(jo);
           // json.put(jo);
        }
        System.out.println(json);





    }
}
